﻿<?php include("template/baglanti.php"); include ("upload.php"); include("template/header.php"); ?>   
<link rel="stylesheet" type="text/css" href="css/main.css" />
<?php
		$ok = ""; 
		
		$phid = intval($_GET['phid']);
		$id = intval($_GET['id']);
		$ctID = intval($_GET['ctID']);
		
		//Categori Listeleme
		$query = ("SELECT * FROM photogaleri WHERE `photoId` ='$phid'");
		$sql = mysql_query($query);
		$row = mysql_fetch_assoc($sql);		
		$save = $_POST['save'];
		$Phphoto= $row['Phphoto'];
		$Phsphoto= $row['Phsphoto'];

		
		if ($save) {




			//Categori Düzenleme
			$Phname = $_POST['Phname'];
			$Phinfo = $_POST['Phinfo'];
			$Phinfocn = $_POST['Phinfocn'];
			$Phshow = $_POST['Phshow'];
			
$dosyasmall = $_FILES['dosyasmall'];
if ( $dosyasmall['name'] != '') {
$Phsphoto = upload_pic($dosyasmall);
}

$dosya = $_FILES['dosya'];
if ( $dosya['name'] != '') {
$Phphoto = upload_pic($dosya);
}

			
							
mysql_query("update photogaleri set


`categori_id` = '$ctID',
`PdID` = '$id',
`Phname` = '$Phname',
`Phinfo` = '$Phinfo',
`Phinfocn` = '$Phinfocn',
`Phsphoto` = '$Phsphoto',
`Phphoto` = '$Phphoto',
`Phshow` = '$Phshow'
			
			WHERE  `photoId` = '$phid'
			
			");

			$ok = "done";
		}
	
		if(!$ok) {



	
		?>



<div class="clear"> </div>
<div class="wrapper">

<div class="menu radius flt">
<?php include("./template/menu.php") ?>
 </div>

<div class="wrapperInside radius flt"> 

<div class="wrapperInsideCapture"> Products Edit </div>

<div class="wpForm"> 

<form class="validate" name="form1" method="post" id="save" enctype="multipart/form-data"  >
	
	



	<div class="wpFormLabelBox">
	<div class="wpFormLabel">Products Category and Sub Category Name</div>
	<div class="wpFormText radius"> 

	<?php

		$cns = ("SELECT * FROM `categori` WHERE `categori_id` = '$ctID' ");
		$cn = mysql_query($cns);
		$cnl = mysql_fetch_assoc($cn);
		$pns = ("SELECT * FROM `products` WHERE `PdID` = '$id' ");
		$pn = mysql_query($pns);
		$pnl = mysql_fetch_assoc($pn);
		
	?>

	<input type="text" value="<?=$cnl['categori_name']?> I <?=$pnl['Pdname']?>" readonly >

	</div>
	</div>

	<div class="wpFormLabelBox">
	<div class="wpFormLabel"> Products Name</div>
	<div class="wpFormText radius"> <input name="Phname" type="text" value="<?=$row['Phname'];?>" /></div>
	</div>





	<div class="wpFormLabelBox">
	<div class="wpFormLabel "> Products Detail</div>
	<div class="wpFormText" style="display:block; height:100%;">
	<textarea name="Phinfo" id="textarea" cols="45"rows="5" /  class="mceEditor"> <?=$row['Phinfo'];?></textarea>
	</div>
	</div>
    
    	<div class="wpFormLabelBox">
	<div class="wpFormLabel "> Products (Chinese)Detail</div>
	<div class="wpFormText" style="display:block; height:100%;">
	<textarea name="Phinfocn" id="textarea" cols="45"rows="5" /  class="mceEditor"> <?=$row['Phinfocn'];?></textarea>
	</div>
	</div>




	<div class="wpFormLabelBox">
	<div class="wpFormLabel"> Small Photo (250px x 250px)</div>

	<?php if(!empty($row['Phsphoto'])):?>
	<img src="../upload/products/<?=$row['Phsphoto'];?>" ><?php else: ?> <img src="../upload/images/noneimg.jpg"> <?php endif; ?><br><br>
	<input type="file" class="nicefileinput wpFormUpload" name="dosyasmall" />
	</div>


	<div class="wpFormLabelBox">
	<div class="wpFormLabel"> Photo (1000px x 1000px)</div>

	<?php if(!empty($row['Phphoto'])):?>
	<img src="../upload/products/<?=$row['Phphoto'];?>" width="250px" height="250px" ><?php else: ?> <img src="../upload/images/noneimg.jpg"> <?php endif; ?><br><br>
	<input type="file" class="nicefileinput wpFormUpload" name="dosya" />
	</div>





<div class="wpFormLabelBox">
<div class="wpFormLabel">Show</div>
<div class="wpFormCheck"> 
<input id="radio1" type="radio" name="Phshow" value="1" <?php if($row['Phshow'] == 1 ) echo"checked";?> >  <label> Yes </label>
<input id="radio1" type="radio" name="Phshow" value="0" style="margin-left:24px;" <?php if($row['Phshow'] == 0 ) echo"checked";?>>  <label> No</label>
 </div>
</div>


<div class="wpFormLabelBox">
<div class="wpFormButton">
<input type="submit" name="save"  id="save" value="Save" class="radius">
</div>
</div>


</form>


   
</div>

<?php }	if ($ok == "done"): ?>
<div class="welldone"><img src="images/ok.jpg" width="300" height="300"><br>
Your process well done !<br><a href="productsGaleryShow.php?id=<?=$id?>&ctID=<?=$ctID?>">:: OK :: </a> </div>
<?php endif; ?>
</div>
</div>







<?php include("template/footer.php") ?>

<?php 

function upload_pic($file)
{
	
	
	$upload = new upload($file);
	
	$new_name = substr(md5(time()),0,6).substr(md5(rand(0,100000)),0,6);
	
	
	#big
	$upload->file_new_name_body     = $new_name;
	$upload->process('../upload/products');
	if($upload->processed){
		$upload->clean();
		return $new_name.'.jpg';
	}
	
	echo 'Hata:'.$upload->error.'-'.$upload->file_dst_path;exit;

}
?>

